package main

import (
	. "MessageParser"
	. "Network"
	. "fmt"
	. "time"
)

func handleMessage(str string) {
	Println("[handleMessage] ", str)
}

func main() {

	for i := 0; i < 100; i++ {
		client := NewClient("localhost", 9999)
		// Register callback fun
		client.ReadString(handleMessage)

		for j := 0; j < 10; j++ {
			name := Sprintf("name_%d", (i+j)*19)
			msg := MessageRequest{
				(i + j + 1) * 12,
				i % 3,
				name,
				"127.0.0.1",
				23467}
			str, err := msg.Deserialization()
			if err != nil {
				Println(err)
			}
			client.WriteString(str)
		}
		Sleep(Second * 3)
		client.Stop()
	}

}
